class Solution {
    public int[] productExceptSelf(int[] nums) {
        int len=nums.length;
        int []res=new int[len];
        int [] l=new int[len];
        int [] r=new int[len];
        l[0]=1;
        for(int i=1;i<len;i++)
        {
            l[i]=nums[i-1]*l[i-1];
        }
        r[len-1]=1;
        for(int i=len-2;i>=0;i--)
        {
            r[i]=nums[i+1]*r[i+1];
        }
        for(int i=0;i<len;i++)
        {
            res[i]=l[i]*r[i];
        }
        return res;
    }
}
